import random
    
def getNextNumberFor(klass):
    num = klass.all().order('-number').get()
    if num != None:
        return num.number+1
    else:
        return 0

def makeMovementLink(linkText, zone, x, y):
    """ Produces a link, if appropriate that moves the player to a valid location"""
    template = "/moveto/%d,%d,%d"
    link = template % (zone.number, x, y)
    return "<a class=\"movement-link\" href='%s'>%s</a>" % (link, linkText)
